//
//  Niu_AnalystTableViewCell.m
//  RedManStock
//
//  Created by lanou3g on 15/7/22.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "Niu_AnalystTableViewCell.h"
#import "Analyst.h"
#import "NiuRen.h"
@implementation Niu_AnalystTableViewCell

- (UIImageView *)avatarImageView{
    if (_avatarImageView==nil) {
        _avatarImageView=[[UIImageView alloc]init];
    }
    return _avatarImageView;
}

- (void)setNiuren:(NiuRen *)niuren{
    if (_niuren!=niuren) {
        _niuren=niuren;
    }
    self.avatarButton.layer.cornerRadius=25;
    self.avatarButton.layer.masksToBounds=YES;
//    self.avatarButton.contentMode=UIViewContentModeScaleAspectFill;
//    [self.avatarButton setBackgroundImage:self.avatarImageView.image forState:UIControlStateNormal];
    
    self.nameLabel.text=niuren.memberSB.name;
    self.dateLabel.text=niuren.tradeSB.dateSB;
    self.typeLabel.text=niuren.tradeSB.typeSB;
    if ([niuren.tradeSB.typeSB isEqualToString:@"买入"]) {
        self.typeLabel.textColor=[UIColor redColor];
    }
    else{
        self.typeLabel.textColor=[UIColor greenColor];
    }
    self.simpleStockLabel.text=niuren.tradeSB.simpleStockStr;
    self.simpleStockLabel.textColor=[UIColor colorWithRed:0.270 green:0.676 blue:0.709 alpha:1.000];
    
    self.tradeLabel.hidden=NO;
    self.tradeLabel.frame=CGRectMake(self.tradeLabel.frame.origin.x, self.tradeLabel.frame.origin.y, self.tradeLabel.frame.size.width, 21);
    self.tradeLabel.text=niuren.tradeSB.tradeStr;
    self.rightTopLabel.text=niuren.totalText;
    self.yieldLabel.text=niuren.memberSB.totalYieldRateSB;
    [self.moreButton setTitle:@"膜拜" forState:UIControlStateNormal];
    [self.moreButton setTitleColor:[UIColor colorWithRed:0.270 green:0.676 blue:0.709 alpha:1.000] forState:UIControlStateNormal];
    
}

- (void)setAnalyst:(Analyst *)analyst{
    if (_analyst!=analyst) {
        _analyst=analyst;
    }
    
    self.avatarButton.layer.cornerRadius=25;
    self.avatarButton.layer.masksToBounds=YES;
//    self.avatarButton.contentMode=UIViewContentModeScaleAspectFit;
//    [self.avatarButton setBackgroundImage:self.avatarImageView.image forState:UIControlStateNormal];
    self.nameLabel.text=analyst.name;
    self.dateLabel.text=analyst.viewPointSB.dateSB;
    self.typeLabel.textColor=[UIColor blackColor];
    self.typeLabel.text=analyst.recomendText;
    self.simpleStockLabel.text=analyst.viewPointSB.simpleStockStr;
    
//    分析师没有这个label，所以height要设置为0
#warning 这里设置高度为0，是没有效果的，因为IB的优先级更高
    self.tradeLabel.frame=CGRectMake(self.tradeLabel.frame.origin.x, self.tradeLabel.frame.origin.y, self.tradeLabel.frame.size.width, 0);
    self.tradeLabel.hidden=YES;
    
    self.rightTopLabel.text=analyst.weekUpText;
    self.yieldLabel.text=analyst.avgWeekYieldRateSB;
    [self.moreButton setTitle:@"查看" forState:UIControlStateNormal];
}

#warning button的事件还没有添加，膜拜还没有添加

- (void)awakeFromNib {
    // Initialization code
//    self.avatarButton.imageView.contentMode=UIViewContentModeScaleAspectFill;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
